package com.baitiaojun.api.domain.video;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.util.Date;
import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@ApiModel("视频")
@Document(indexName = "video")
public class Video {

    @Id
    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(readOnly = true)
    private Long id;

    @JsonSerialize(using = ToStringSerializer.class)
    @Field(type = FieldType.Long)
    @ApiModelProperty(readOnly = true)
    private Long userId;

    @Field(type = FieldType.Keyword, index = false)
    @ApiModelProperty(value = "视频文件路径", required = true)
    private String url;

    @Field(type = FieldType.Keyword, index = false)
    @ApiModelProperty(value = "视频缩略图路径", required = true)
    private String thumbnail;

    @Field(type = FieldType.Text)
    @ApiModelProperty(value = "视频标题", required = true)
    private String title;

    @Field(type = FieldType.Keyword)
    @ApiModelProperty(value = "视频类型", required = true, example = "原创，转载")
    private String type;

    @Field(type = FieldType.Keyword, index = false)
    @ApiModelProperty(value = "视频播放时长", required = true)
    private String duration;

    @ApiModelProperty(value = "视频分区", required = true, example = "生活 美食 游戏 音乐 时尚 知识 娱乐 影视 动画 汽车 动物圈 舞蹈 科技 国创 鬼畜")
    @Field(type = FieldType.Keyword)
    private String area;

    @ApiModelProperty(hidden = true)
    @Field(type = FieldType.Date, index = false)
    private Date createtime;

    @ApiModelProperty(hidden = true)
    @Field(type = FieldType.Date, index = false)
    private Date updatetime;

    @ApiModelProperty(value = "视频描述")
    @Field(type = FieldType.Text, index = false)
    private String description;

    @ApiModelProperty(hidden = true)
    @Field(type = FieldType.Text)
    private String creator;

    @ApiModelProperty(value = "视频标签", required = true, example = "[{\"value\":\"java\"},{\"value\":\"微信小程序\"},{\"value\":\"学习\"}]")
    @Field(type = FieldType.Object)
    private List<Tag> tags;

    @ApiModelProperty(hidden = true)
    @Field(type = FieldType.Integer, index = false)
    private Integer viewCount = 0;

    @ApiModelProperty(hidden = true)
    @Field(type = FieldType.Integer, index = false)
    private Integer commentCount = 0;

    @ApiModelProperty(hidden = true)
    @Field(type = FieldType.Integer, index = false)
    private Integer lickCount = 0;

    @ApiModelProperty(hidden = true)
    @Field(type = FieldType.Integer, index = false)
    private Integer coinCount = 0;

    @ApiModelProperty(hidden = true)
    @Field(type = FieldType.Integer, index = false)
    private Integer collectionCount = 0;
}